<%@page import="com.sinba.itsm.bugfix.RequestWrapper"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="com.sinba.common.dto.PageDTO"%>
<%@page import="com.sinba.common.news.dto.NewsQueryDTO"%>
<%@page import="com.sinba.common.news.service.INewsService"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="../language.jsp" %>
<%
ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
INewsService ns = (INewsService)ac.getBean("newsService");
NewsQueryDTO queryDTO = new NewsQueryDTO();
queryDTO.setNewType((String)request.getParameter("newType"));
queryDTO.setLimit(10);
int pages = 1;
String sidx = "createTime";
String sord="desc";
if(request.getParameter("pages")!=null && request.getParameter("_pages")!=""){
	pages = Integer.parseInt(request.getParameter("pages"));
}
int rows = 10;
int start = ( pages - 1 ) * rows;
queryDTO.setStart( start );
queryDTO.setLimit( rows );
PageDTO pagedto = ns.findNewsPager(queryDTO,sord,sidx);
if(pagedto!=null){
	pagedto.setPage( pages );
	pagedto.setRows( rows );
}
request.setAttribute("newType",(String)request.getParameter("newType"));
request.setAttribute("pageDTO",pagedto);
session.setAttribute("middle", "信息管理");
session.setAttribute("end", "公司公告");	
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1" >
<title><fmt:message key="i18n.newsGrid"/>-<fmt:message key="i18n.title"/> </title>
<link rel="shortcut icon" href="../index/favicon.png" />
<jsp:include page="common.jsp"></jsp:include>
</head>
<body>
	<jsp:include page="page_head.jsp"></jsp:include>
		<!-- ROW 3 -->
		<div class="row">
			<div class="col-md-12">
				<div class="box border primary">
					<div class="box-title">
						<h4>
							<i class="fa fa-columns"></i> <span
								class="hidden-inline-mobile"><span>
									<c:if test="${newType eq 'WebAffiche' }">公司公告</c:if>
									<c:if test="${newType eq 'WebNews' }"><fmt:message key="i18n.news" /></c:if>
									<c:if test="${newType eq 'Rule' }"><fmt:message key="i18n.communStation" /></c:if>
								</span></span>
						</h4>
					</div>
					<div class="box-body">
						<div class="tabbable">
							<div class="tab-content">
								<div class="tab-pane active">
									<table
										class="table table-striped table-bordered table-hover">
										<thead>
											<tr>
												<th><fmt:message key="i18n.titleChild"/></th>
        										<th><fmt:message key="i18n.releseTime"/></th>
											</tr>
										</thead>
										<tbody>
											<c:forEach items="${pageDTO.data}" var="data">
						        				<tr>
						        					<td><a href="news!newsInfo.action?newsQueryDTO.newId=${data.newId}">${data.title}</a></td>
						        					<td><fmt:formatDate type="date" value="${data.createTime}"  pattern="yyyy-MM-dd HH:mm:ss" /></td>
						        				</tr>
						        			</c:forEach>
						        			<c:if test="${empty pageDTO.data}">
						        				<tr>
						        					<td colspan="2"><fmt:message key="i18n.noData"/>!</td>
						        				</tr>
						        			</c:if>
											<tr>
													<td colspan="2" style="text-align: right;">
													<a style="color: blue;" href="${pageUrl }&pages=1"><fmt:message key="i18n.firstPage"/></a>
													<c:if test="${pageDTO.page > 1}">
														<a style="color: blue;" href="${pageUrl }&pages=${pageDTO.page-1}"><fmt:message key="i18n.upPage"/></a>
													</c:if>
													<a>${pageDTO.page}/${pageDTO.total}</a>
													<c:if test="${pageDTO.page+1<=pageDTO.total}">
														<a style="color: blue;" href="${pageUrl }&pages=${pageDTO.page+1}"><fmt:message key="i18n.nextPage"/></a>
													</c:if>
													<a style="color: blue;" href="${pageUrl }&pages=${pageDTO.total}"><fmt:message key="i18n.endPage"/></a>
													<a><fmt:message key="i18n.total"/>${pageDTO.totalSize}<fmt:message key="i18n.tiao"/></a>
													</td>
												</tr>
										</tbody>
									</table>
								</div>
							</div>
						</div>
					</div>
				</div>
		</div>
	</div>
	<jsp:include page="page_foot.jsp"></jsp:include>

</body>
</html>